/*
 * Copyright (c) 2015, 张涛.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.kymjs.themvp.samples.demo4;

import com.kymjs.themvp.samples.ResourceTable;
import com.kymjs.themvp.view.AppDelegate;
import ohos.agp.components.Text;
import ohos.agp.components.TextField;

/**
 * @author kymjs (http://www.kymjs.com/) on 10/26/15.
 */
public class FragmentDelegate extends AppDelegate {

    @Override
    public int getRootLayoutId() {
        return ResourceTable.Layout_fragment_user;
    }

    @Override
    public void initWidget() {
        super.initWidget();
        TextField et = get(ResourceTable.Id_editText);
        TextField et2 = get(ResourceTable.Id_editText2);
        et.setHint("姓名");
        et2.setHint("年龄");
    }

    /**
     * getText
     * @param id id
     * @return String
     */
    public String getText(int id) {
        TextField et = get(id);
        return et.getText();
    }

    /**
     * setResult
     * @param name name
     * @param age age
     */
    public void setResult(String name, String age) {
        Text textView = get(ResourceTable.Id_text);
        textView.setText(String.format("姓名+ %s + 年龄 + %s", name, age));
    }
}
